/*
 * @Author: 檃
 * @Date: 2022-04-27 16:10:18
 * @LastEditTime: 2022-06-20 13:17:55
 * @Description:
 * @LastEditors: 檃
 */
import { useEffect } from 'react'
import { Route, Routes, useNavigate } from 'react-router'

import { configs } from './configs'

const Redirect = ({ to }) => {
  const navigate = useNavigate()
  useEffect(() => {
    navigate(to)
  })
  return null
}

const RouteList = () => {
  return (
    <Routes>
      {configs.map((item) => {
        const Comp = item.component
        return (
          <Route key={item.path} path={item.path} element={<Comp></Comp>} />
        )
      })}
      <Route path="/*" element={<Redirect to="/test" />} />
    </Routes>
  )
}

export default RouteList
